package com.example.springboot.mapper;

import com.example.springboot.pojo.Announcement;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface AnnouncementMapper {

    @Select("select * from announcement")
    List<Announcement> findAll();
    @Select("select * from announcement where id=#{id}")
    Announcement findById(Integer id);

    @Insert("insert into announcement(title,content,img,create_time) " +
            "values(#{title},#{content},#{img},now())")
    void create(Announcement announcement);

    @Update("update announcement set title=#{title},content=#{content},img=#{img}where id=#{id}")
    void update(Announcement announcement);

    @Delete("delete from announcement where id=#{id}")
    void delete(Integer id);

    //根据标题查找
    @Select("select * from announcement where title like concat('%',#{title},'%')")
    List<Announcement> findByTitle(String title);
}
